from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from apps.goods.models import SPUSpecification, SPU
from rest_framework.permissions import IsAdminUser
from ..serializers.specs import SPUSpecificationSerialzier, SPUSerialzier
from ..utils import PageNum



class SpecsView(ModelViewSet):

    # 指定查询集
    queryset = SPUSpecification.objects.all()
    serializer_class = SPUSpecificationSerialzier
    permission_classes = [IsAdminUser]
    pagination_class = PageNum

    def simple(self,request):

        spus = SPU.objects.all()

        ser = SPUSerialzier(spus,many=True)

        return Response(ser.data)